package com.carrent.demo.Utils;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
public class R implements Serializable {

    private Integer code;
    private Object  data;
    private Integer total;
    private String  msg;
    private Map map = new HashMap(); //动态数据


    public  static  R success(Object obj)
    {
        R r= new R();
        r.data = obj;
        r.code = 1;
        return r;
    }

    public  static  R success(Object obj,Integer count)
    {
        R r= new R();
        r.data = obj;
        r.total = count;
        r.code = 1;
        return r;
    }

    public  static  R error(String msg)
    {
        R r = new R();
        r.code = 0;
        r.msg = msg;
        return  r;
    }

    public  R add(String key,String value)
    {
        this.map.put(key,value);
        return this;
    }






}
